package com.dailycodebuffer.springbootmongodb.controller;




import com.dailycodebuffer.springbootmongodb.collection.Supplier;
import com.dailycodebuffer.springbootmongodb.service.SupplierService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;


/**
 * 控制层
 *
 * @author makejava
 * @since 2025-01-04 00:23:43
 */
@RestController
@RequestMapping("/supplier")
@AllArgsConstructor
public class SupplierController {

	private SupplierService supplierService;

	/**
	 * 获取列表(分页)
	 */
	@GetMapping("/list")
	public Page<Supplier> list(Pageable page) {
		return  supplierService.list(page);
	}
	/**
	 * 获取
	 */
	@GetMapping("{id}")
	public Supplier get(@PathVariable("id") Integer id) {
		return supplierService.findById(id);
	}

	/**
	 * 添加
	 */
	@PostMapping("/add")
	public void add(@RequestBody Supplier supplier) {
		supplierService.save(supplier);
	}

}

